package com.group.app.example.common.support;

import org.hibernate.dialect.PostgreSQL94Dialect;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
import org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor;

import java.sql.Types;

public class JsonPostgresDialect extends PostgreSQL94Dialect {
    @Override
    public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor) {
        switch (sqlTypeDescriptor.getSqlType()){
            case Types.CLOB | Types.BLOB | 1111:
                return VarbinaryTypeDescriptor.INSTANCE;
            default:
        }
        return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
    }
    public JsonPostgresDialect(){
        super();
        registerHibernateType(1111,"string");
    }
}
